package com.wantup.miaosha.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wantup.miaosha.entity.TblUser;
import com.wantup.miaosha.entity.TblUser2;
import com.wantup.miaosha.pojo.UserPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface TblUserMapper extends BaseMapper<TblUser> {

    @Select("SELECT id,name FROM tbl_user WHERE id = #{id}")
    public TblUser getUserInfoById(@Param("id") Integer id);

    @Insert("INSERT INTO tbl_user2(name,password) VALUES(#{tblUser.name},#{tblUser.password})")
    public int userRegisterMapper(@Param("tblUser") TblUser2 tblUser) throws Exception;


    @Select("SELECT COUNT(1) FROM tbl_user2 WHERE name=#{userPojo.name} AND password = #{userPojo.password}")
    Integer userExistMapper(@Param("userPojo") UserPojo userPojo) throws Exception;

    @Select("SELECT id,name,password FROM tbl_user2 WHERE name=#{userPojo.name} AND password = #{userPojo.password}")
    TblUser userLoginMapper(@Param("userPojo") UserPojo userPojo) throws Exception;

    @Select("SELECT id,name,password FROM tbl_user2 WHERE name=#{name}")
    TblUser userLoginMapper2(@Param("name") String name);

    //-----------------------------------------------------------------//

    @Select("SELECT * FROM tbl_user WHERE name=#{name}")
    public TblUser getUserById(@Param("name") String name);


}
